Left Termination of the query pattern log2_in_2(g, a) w.r.t. the given Prolog program could successfully be proven:



Prolog
  ↳ PrologToPiTRSProof

Clauses:

log2(X, Y) :- log2(X, 0, s(0), Y).
log2(s(s(X)), Half, Acc, Y) :- log2(X, s(Half), Acc, Y).
log2(X, s(s(Half)), Acc, Y) :- ','(small(X), log2(Half, s(0), s(Acc), Y)).
log2(X, Half, Y, Y) :- ','(small(X), small(Half)).
small(0).
small(s(0)).

Queries:

log2(g,a).

We use the technique of [30]. With regard to the inferred argument filtering the predicates were used in the following modes:
log2_in: (b,f)
log2_in: (b,b,b,f)
Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

log2_in_ga(X, Y) → U1_ga(X, Y, log2_in_ggga(X, 0, s(0), Y))
log2_in_ggga(s(s(X)), Half, Acc, Y) → U2_ggga(X, Half, Acc, Y, log2_in_ggga(X, s(Half), Acc, Y))
log2_in_ggga(X, s(s(Half)), Acc, Y) → U3_ggga(X, Half, Acc, Y, small_in_g(X))
small_in_g(0) → small_out_g(0)
small_in_g(s(0)) → small_out_g(s(0))
U3_ggga(X, Half, Acc, Y, small_out_g(X)) → U4_ggga(X, Half, Acc, Y, log2_in_ggga(Half, s(0), s(Acc), Y))
log2_in_ggga(X, Half, Y, Y) → U5_ggga(X, Half, Y, small_in_g(X))
U5_ggga(X, Half, Y, small_out_g(X)) → U6_ggga(X, Half, Y, small_in_g(Half))
U6_ggga(X, Half, Y, small_out_g(Half)) → log2_out_ggga(X, Half, Y, Y)
U4_ggga(X, Half, Acc, Y, log2_out_ggga(Half, s(0), s(Acc), Y)) → log2_out_ggga(X, s(s(Half)), Acc, Y)
U2_ggga(X, Half, Acc, Y, log2_out_ggga(X, s(Half), Acc, Y)) → log2_out_ggga(s(s(X)), Half, Acc, Y)
U1_ga(X, Y, log2_out_ggga(X, 0, s(0), Y)) → log2_out_ga(X, Y)

The argument filtering Pi contains the following mapping:
log2_in_ga(x1, x2)  =  log2_in_ga(x1)
U1_ga(x1, x2, x3)  =  U1_ga(x3)
log2_in_ggga(x1, x2, x3, x4)  =  log2_in_ggga(x1, x2, x3)
s(x1)  =  s(x1)
U2_ggga(x1, x2, x3, x4, x5)  =  U2_ggga(x5)
U3_ggga(x1, x2, x3, x4, x5)  =  U3_ggga(x2, x3, x5)
small_in_g(x1)  =  small_in_g(x1)
0  =  0
small_out_g(x1)  =  small_out_g
U4_ggga(x1, x2, x3, x4, x5)  =  U4_ggga(x5)
U5_ggga(x1, x2, x3, x4)  =  U5_ggga(x2, x3, x4)
U6_ggga(x1, x2, x3, x4)  =  U6_ggga(x3, x4)
log2_out_ggga(x1, x2, x3, x4)  =  log2_out_ggga(x4)
log2_out_ga(x1, x2)  =  log2_out_ga(x2)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

log2_in_ga(X, Y) → U1_ga(X, Y, log2_in_ggga(X, 0, s(0), Y))
log2_in_ggga(s(s(X)), Half, Acc, Y) → U2_ggga(X, Half, Acc, Y, log2_in_ggga(X, s(Half), Acc, Y))
log2_in_ggga(X, s(s(Half)), Acc, Y) → U3_ggga(X, Half, Acc, Y, small_in_g(X))
small_in_g(0) → small_out_g(0)
small_in_g(s(0)) → small_out_g(s(0))
U3_ggga(X, Half, Acc, Y, small_out_g(X)) → U4_ggga(X, Half, Acc, Y, log2_in_ggga(Half, s(0), s(Acc), Y))
log2_in_ggga(X, Half, Y, Y) → U5_ggga(X, Half, Y, small_in_g(X))
U5_ggga(X, Half, Y, small_out_g(X)) → U6_ggga(X, Half, Y, small_in_g(Half))
U6_ggga(X, Half, Y, small_out_g(Half)) → log2_out_ggga(X, Half, Y, Y)
U4_ggga(X, Half, Acc, Y, log2_out_ggga(Half, s(0), s(Acc), Y)) → log2_out_ggga(X, s(s(Half)), Acc, Y)
U2_ggga(X, Half, Acc, Y, log2_out_ggga(X, s(Half), Acc, Y)) → log2_out_ggga(s(s(X)), Half, Acc, Y)
U1_ga(X, Y, log2_out_ggga(X, 0, s(0), Y)) → log2_out_ga(X, Y)

The argument filtering Pi contains the following mapping:
log2_in_ga(x1, x2)  =  log2_in_ga(x1)
U1_ga(x1, x2, x3)  =  U1_ga(x3)
log2_in_ggga(x1, x2, x3, x4)  =  log2_in_ggga(x1, x2, x3)
s(x1)  =  s(x1)
U2_ggga(x1, x2, x3, x4, x5)  =  U2_ggga(x5)
U3_ggga(x1, x2, x3, x4, x5)  =  U3_ggga(x2, x3, x5)
small_in_g(x1)  =  small_in_g(x1)
0  =  0
small_out_g(x1)  =  small_out_g
U4_ggga(x1, x2, x3, x4, x5)  =  U4_ggga(x5)
U5_ggga(x1, x2, x3, x4)  =  U5_ggga(x2, x3, x4)
U6_ggga(x1, x2, x3, x4)  =  U6_ggga(x3, x4)
log2_out_ggga(x1, x2, x3, x4)  =  log2_out_ggga(x4)
log2_out_ga(x1, x2)  =  log2_out_ga(x2)


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

LOG2_IN_GA(X, Y) → U1_GA(X, Y, log2_in_ggga(X, 0, s(0), Y))
LOG2_IN_GA(X, Y) → LOG2_IN_GGGA(X, 0, s(0), Y)
LOG2_IN_GGGA(s(s(X)), Half, Acc, Y) → U2_GGGA(X, Half, Acc, Y, log2_in_ggga(X, s(Half), Acc, Y))
LOG2_IN_GGGA(s(s(X)), Half, Acc, Y) → LOG2_IN_GGGA(X, s(Half), Acc, Y)
LOG2_IN_GGGA(X, s(s(Half)), Acc, Y) → U3_GGGA(X, Half, Acc, Y, small_in_g(X))
LOG2_IN_GGGA(X, s(s(Half)), Acc, Y) → SMALL_IN_G(X)
U3_GGGA(X, Half, Acc, Y, small_out_g(X)) → U4_GGGA(X, Half, Acc, Y, log2_in_ggga(Half, s(0), s(Acc), Y))
U3_GGGA(X, Half, Acc, Y, small_out_g(X)) → LOG2_IN_GGGA(Half, s(0), s(Acc), Y)
LOG2_IN_GGGA(X, Half, Y, Y) → U5_GGGA(X, Half, Y, small_in_g(X))
LOG2_IN_GGGA(X, Half, Y, Y) → SMALL_IN_G(X)
U5_GGGA(X, Half, Y, small_out_g(X)) → U6_GGGA(X, Half, Y, small_in_g(Half))
U5_GGGA(X, Half, Y, small_out_g(X)) → SMALL_IN_G(Half)

The TRS R consists of the following rules:

log2_in_ga(X, Y) → U1_ga(X, Y, log2_in_ggga(X, 0, s(0), Y))
log2_in_ggga(s(s(X)), Half, Acc, Y) → U2_ggga(X, Half, Acc, Y, log2_in_ggga(X, s(Half), Acc, Y))
log2_in_ggga(X, s(s(Half)), Acc, Y) → U3_ggga(X, Half, Acc, Y, small_in_g(X))
small_in_g(0) → small_out_g(0)
small_in_g(s(0)) → small_out_g(s(0))
U3_ggga(X, Half, Acc, Y, small_out_g(X)) → U4_ggga(X, Half, Acc, Y, log2_in_ggga(Half, s(0), s(Acc), Y))
log2_in_ggga(X, Half, Y, Y) → U5_ggga(X, Half, Y, small_in_g(X))
U5_ggga(X, Half, Y, small_out_g(X)) → U6_ggga(X, Half, Y, small_in_g(Half))
U6_ggga(X, Half, Y, small_out_g(Half)) → log2_out_ggga(X, Half, Y, Y)
U4_ggga(X, Half, Acc, Y, log2_out_ggga(Half, s(0), s(Acc), Y)) → log2_out_ggga(X, s(s(Half)), Acc, Y)
U2_ggga(X, Half, Acc, Y, log2_out_ggga(X, s(Half), Acc, Y)) → log2_out_ggga(s(s(X)), Half, Acc, Y)
U1_ga(X, Y, log2_out_ggga(X, 0, s(0), Y)) → log2_out_ga(X, Y)

The argument filtering Pi contains the following mapping:
log2_in_ga(x1, x2)  =  log2_in_ga(x1)
U1_ga(x1, x2, x3)  =  U1_ga(x3)
log2_in_ggga(x1, x2, x3, x4)  =  log2_in_ggga(x1, x2, x3)
s(x1)  =  s(x1)
U2_ggga(x1, x2, x3, x4, x5)  =  U2_ggga(x5)
U3_ggga(x1, x2, x3, x4, x5)  =  U3_ggga(x2, x3, x5)
small_in_g(x1)  =  small_in_g(x1)
0  =  0
small_out_g(x1)  =  small_out_g
U4_ggga(x1, x2, x3, x4, x5)  =  U4_ggga(x5)
U5_ggga(x1, x2, x3, x4)  =  U5_ggga(x2, x3, x4)
U6_ggga(x1, x2, x3, x4)  =  U6_ggga(x3, x4)
log2_out_ggga(x1, x2, x3, x4)  =  log2_out_ggga(x4)
log2_out_ga(x1, x2)  =  log2_out_ga(x2)
U4_GGGA(x1, x2, x3, x4, x5)  =  U4_GGGA(x5)
U5_GGGA(x1, x2, x3, x4)  =  U5_GGGA(x2, x3, x4)
LOG2_IN_GGGA(x1, x2, x3, x4)  =  LOG2_IN_GGGA(x1, x2, x3)
U6_GGGA(x1, x2, x3, x4)  =  U6_GGGA(x3, x4)
U3_GGGA(x1, x2, x3, x4, x5)  =  U3_GGGA(x2, x3, x5)
U1_GA(x1, x2, x3)  =  U1_GA(x3)
U2_GGGA(x1, x2, x3, x4, x5)  =  U2_GGGA(x5)
SMALL_IN_G(x1)  =  SMALL_IN_G(x1)
LOG2_IN_GA(x1, x2)  =  LOG2_IN_GA(x1)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

Pi DP problem:
The TRS P consists of the following rules:

LOG2_IN_GA(X, Y) → U1_GA(X, Y, log2_in_ggga(X, 0, s(0), Y))
LOG2_IN_GA(X, Y) → LOG2_IN_GGGA(X, 0, s(0), Y)
LOG2_IN_GGGA(s(s(X)), Half, Acc, Y) → U2_GGGA(X, Half, Acc, Y, log2_in_ggga(X, s(Half), Acc, Y))
LOG2_IN_GGGA(s(s(X)), Half, Acc, Y) → LOG2_IN_GGGA(X, s(Half), Acc, Y)
LOG2_IN_GGGA(X, s(s(Half)), Acc, Y) → U3_GGGA(X, Half, Acc, Y, small_in_g(X))
LOG2_IN_GGGA(X, s(s(Half)), Acc, Y) → SMALL_IN_G(X)
U3_GGGA(X, Half, Acc, Y, small_out_g(X)) → U4_GGGA(X, Half, Acc, Y, log2_in_ggga(Half, s(0), s(Acc), Y))
U3_GGGA(X, Half, Acc, Y, small_out_g(X)) → LOG2_IN_GGGA(Half, s(0), s(Acc), Y)
LOG2_IN_GGGA(X, Half, Y, Y) → U5_GGGA(X, Half, Y, small_in_g(X))
LOG2_IN_GGGA(X, Half, Y, Y) → SMALL_IN_G(X)
U5_GGGA(X, Half, Y, small_out_g(X)) → U6_GGGA(X, Half, Y, small_in_g(Half))
U5_GGGA(X, Half, Y, small_out_g(X)) → SMALL_IN_G(Half)

The TRS R consists of the following rules:

log2_in_ga(X, Y) → U1_ga(X, Y, log2_in_ggga(X, 0, s(0), Y))
log2_in_ggga(s(s(X)), Half, Acc, Y) → U2_ggga(X, Half, Acc, Y, log2_in_ggga(X, s(Half), Acc, Y))
log2_in_ggga(X, s(s(Half)), Acc, Y) → U3_ggga(X, Half, Acc, Y, small_in_g(X))
small_in_g(0) → small_out_g(0)
small_in_g(s(0)) → small_out_g(s(0))
U3_ggga(X, Half, Acc, Y, small_out_g(X)) → U4_ggga(X, Half, Acc, Y, log2_in_ggga(Half, s(0), s(Acc), Y))
log2_in_ggga(X, Half, Y, Y) → U5_ggga(X, Half, Y, small_in_g(X))
U5_ggga(X, Half, Y, small_out_g(X)) → U6_ggga(X, Half, Y, small_in_g(Half))
U6_ggga(X, Half, Y, small_out_g(Half)) → log2_out_ggga(X, Half, Y, Y)
U4_ggga(X, Half, Acc, Y, log2_out_ggga(Half, s(0), s(Acc), Y)) → log2_out_ggga(X, s(s(Half)), Acc, Y)
U2_ggga(X, Half, Acc, Y, log2_out_ggga(X, s(Half), Acc, Y)) → log2_out_ggga(s(s(X)), Half, Acc, Y)
U1_ga(X, Y, log2_out_ggga(X, 0, s(0), Y)) → log2_out_ga(X, Y)

The argument filtering Pi contains the following mapping:
log2_in_ga(x1, x2)  =  log2_in_ga(x1)
U1_ga(x1, x2, x3)  =  U1_ga(x3)
log2_in_ggga(x1, x2, x3, x4)  =  log2_in_ggga(x1, x2, x3)
s(x1)  =  s(x1)
U2_ggga(x1, x2, x3, x4, x5)  =  U2_ggga(x5)
U3_ggga(x1, x2, x3, x4, x5)  =  U3_ggga(x2, x3, x5)
small_in_g(x1)  =  small_in_g(x1)
0  =  0
small_out_g(x1)  =  small_out_g
U4_ggga(x1, x2, x3, x4, x5)  =  U4_ggga(x5)
U5_ggga(x1, x2, x3, x4)  =  U5_ggga(x2, x3, x4)
U6_ggga(x1, x2, x3, x4)  =  U6_ggga(x3, x4)
log2_out_ggga(x1, x2, x3, x4)  =  log2_out_ggga(x4)
log2_out_ga(x1, x2)  =  log2_out_ga(x2)
U4_GGGA(x1, x2, x3, x4, x5)  =  U4_GGGA(x5)
U5_GGGA(x1, x2, x3, x4)  =  U5_GGGA(x2, x3, x4)
LOG2_IN_GGGA(x1, x2, x3, x4)  =  LOG2_IN_GGGA(x1, x2, x3)
U6_GGGA(x1, x2, x3, x4)  =  U6_GGGA(x3, x4)
U3_GGGA(x1, x2, x3, x4, x5)  =  U3_GGGA(x2, x3, x5)
U1_GA(x1, x2, x3)  =  U1_GA(x3)
U2_GGGA(x1, x2, x3, x4, x5)  =  U2_GGGA(x5)
SMALL_IN_G(x1)  =  SMALL_IN_G(x1)
LOG2_IN_GA(x1, x2)  =  LOG2_IN_GA(x1)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 1 SCC with 9 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
PiDP
              ↳ UsableRulesProof

Pi DP problem:
The TRS P consists of the following rules:

LOG2_IN_GGGA(s(s(X)), Half, Acc, Y) → LOG2_IN_GGGA(X, s(Half), Acc, Y)
LOG2_IN_GGGA(X, s(s(Half)), Acc, Y) → U3_GGGA(X, Half, Acc, Y, small_in_g(X))
U3_GGGA(X, Half, Acc, Y, small_out_g(X)) → LOG2_IN_GGGA(Half, s(0), s(Acc), Y)

The TRS R consists of the following rules:

log2_in_ga(X, Y) → U1_ga(X, Y, log2_in_ggga(X, 0, s(0), Y))
log2_in_ggga(s(s(X)), Half, Acc, Y) → U2_ggga(X, Half, Acc, Y, log2_in_ggga(X, s(Half), Acc, Y))
log2_in_ggga(X, s(s(Half)), Acc, Y) → U3_ggga(X, Half, Acc, Y, small_in_g(X))
small_in_g(0) → small_out_g(0)
small_in_g(s(0)) → small_out_g(s(0))
U3_ggga(X, Half, Acc, Y, small_out_g(X)) → U4_ggga(X, Half, Acc, Y, log2_in_ggga(Half, s(0), s(Acc), Y))
log2_in_ggga(X, Half, Y, Y) → U5_ggga(X, Half, Y, small_in_g(X))
U5_ggga(X, Half, Y, small_out_g(X)) → U6_ggga(X, Half, Y, small_in_g(Half))
U6_ggga(X, Half, Y, small_out_g(Half)) → log2_out_ggga(X, Half, Y, Y)
U4_ggga(X, Half, Acc, Y, log2_out_ggga(Half, s(0), s(Acc), Y)) → log2_out_ggga(X, s(s(Half)), Acc, Y)
U2_ggga(X, Half, Acc, Y, log2_out_ggga(X, s(Half), Acc, Y)) → log2_out_ggga(s(s(X)), Half, Acc, Y)
U1_ga(X, Y, log2_out_ggga(X, 0, s(0), Y)) → log2_out_ga(X, Y)

The argument filtering Pi contains the following mapping:
log2_in_ga(x1, x2)  =  log2_in_ga(x1)
U1_ga(x1, x2, x3)  =  U1_ga(x3)
log2_in_ggga(x1, x2, x3, x4)  =  log2_in_ggga(x1, x2, x3)
s(x1)  =  s(x1)
U2_ggga(x1, x2, x3, x4, x5)  =  U2_ggga(x5)
U3_ggga(x1, x2, x3, x4, x5)  =  U3_ggga(x2, x3, x5)
small_in_g(x1)  =  small_in_g(x1)
0  =  0
small_out_g(x1)  =  small_out_g
U4_ggga(x1, x2, x3, x4, x5)  =  U4_ggga(x5)
U5_ggga(x1, x2, x3, x4)  =  U5_ggga(x2, x3, x4)
U6_ggga(x1, x2, x3, x4)  =  U6_ggga(x3, x4)
log2_out_ggga(x1, x2, x3, x4)  =  log2_out_ggga(x4)
log2_out_ga(x1, x2)  =  log2_out_ga(x2)
LOG2_IN_GGGA(x1, x2, x3, x4)  =  LOG2_IN_GGGA(x1, x2, x3)
U3_GGGA(x1, x2, x3, x4, x5)  =  U3_GGGA(x2, x3, x5)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
PiDP
                  ↳ PiDPToQDPProof

Pi DP problem:
The TRS P consists of the following rules:

LOG2_IN_GGGA(s(s(X)), Half, Acc, Y) → LOG2_IN_GGGA(X, s(Half), Acc, Y)
LOG2_IN_GGGA(X, s(s(Half)), Acc, Y) → U3_GGGA(X, Half, Acc, Y, small_in_g(X))
U3_GGGA(X, Half, Acc, Y, small_out_g(X)) → LOG2_IN_GGGA(Half, s(0), s(Acc), Y)

The TRS R consists of the following rules:

small_in_g(0) → small_out_g(0)
small_in_g(s(0)) → small_out_g(s(0))

The argument filtering Pi contains the following mapping:
s(x1)  =  s(x1)
small_in_g(x1)  =  small_in_g(x1)
0  =  0
small_out_g(x1)  =  small_out_g
LOG2_IN_GGGA(x1, x2, x3, x4)  =  LOG2_IN_GGGA(x1, x2, x3)
U3_GGGA(x1, x2, x3, x4, x5)  =  U3_GGGA(x2, x3, x5)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
QDP
                      ↳ RuleRemovalProof

Q DP problem:
The TRS P consists of the following rules:

U3_GGGA(Half, Acc, small_out_g) → LOG2_IN_GGGA(Half, s(0), s(Acc))
LOG2_IN_GGGA(X, s(s(Half)), Acc) → U3_GGGA(Half, Acc, small_in_g(X))
LOG2_IN_GGGA(s(s(X)), Half, Acc) → LOG2_IN_GGGA(X, s(Half), Acc)

The TRS R consists of the following rules:

small_in_g(0) → small_out_g
small_in_g(s(0)) → small_out_g

The set Q consists of the following terms:

small_in_g(x0)

We have to consider all (P,Q,R)-chains.
By using the rule removal processor [15] with the following polynomial ordering [25], at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:

LOG2_IN_GGGA(X, s(s(Half)), Acc) → U3_GGGA(Half, Acc, small_in_g(X))
LOG2_IN_GGGA(s(s(X)), Half, Acc) → LOG2_IN_GGGA(X, s(Half), Acc)

Strictly oriented rules of the TRS R:

small_in_g(s(0)) → small_out_g

Used ordering: POLO with Polynomial interpretation [25]:

POL(0) = 0   
POL(LOG2_IN_GGGA(x1, x2, x3)) = 2·x1 + 2·x2 + x3   
POL(U3_GGGA(x1, x2, x3)) = 2 + 2·x1 + x2 + 2·x3   
POL(s(x1)) = 2 + x1   
POL(small_in_g(x1)) = 2 + x1   
POL(small_out_g) = 2   



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
                    ↳ QDP
                      ↳ RuleRemovalProof
QDP
                          ↳ DependencyGraphProof

Q DP problem:
The TRS P consists of the following rules:

U3_GGGA(Half, Acc, small_out_g) → LOG2_IN_GGGA(Half, s(0), s(Acc))

The TRS R consists of the following rules:

small_in_g(0) → small_out_g

The set Q consists of the following terms:

small_in_g(x0)

We have to consider all (P,Q,R)-chains.
The approximation of the Dependency Graph [15,17,22] contains 0 SCCs with 1 less node.